package com.jt.df.web.demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jt.df.dubbo.demo.domain.Demo;
import com.jt.df.dubbo.demo.service.DemoService;

import java.util.Date;
import java.util.Map;

@Controller
public class DemoController {

	@Reference
	private DemoService demoService;
	
	@RequestMapping("/")
	@ResponseBody
	public String sayHello(){
		return demoService.sayHello("guest");
	}
	
	@RequestMapping("/save")
	@ResponseBody
	public Object save(Demo demo){
		Integer id = demoService.save(demo);
		return id;
	}

	@RequestMapping("/web")
	public String web(Map<String,Object> model){
		model.put("time",new Date());
		model.put("message","hi,hello world......");
		return "web";//返回的内容就是templetes下面文件的名称
	}
}
